<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>

<div id="app1">
    <ol>
        <todo-item
                v-for="item in item_list"
                v-bind:todo="item"
                v-bind:key="item.key">
        </todo-item>
    </ol>


</div>


<script>
    Vue.component("todo-item", {
        props: ['todo'],
        template: '<li>{{todo.text}}</li>'
    });
    var app1 = new Vue({
        el : "#app1",
        data : {
            item_list : [
                {id: 0, text: "think in java"},
                {id: 1, text: "study up vue"},
                {id :2, text: "hello world"}
            ],
            msg : "assdsadlja"
        },
        created: function () {
            console.log("created");
            console.log(this.item_list);
        },
        mounted : function () {
            console.log("mountd");
        },
        destroyed : function () {
            console.log("vue instance is destroyed");
        }
    });

    app1.$watch('msg', function (newValue, oldValue) {
        console.log(newValue);
        console.log(oldValue);
    })

    setTimeout(function () {
        app1.$destroy();
    }, 3000);


</script>

</body>
</html>